//
//  TagMigration.swift
//  hello
//
//  Created by 赵康 on 2024/11/11.
//

import Fluent
extension Tag {
	struct Migration: AsyncMigration {
		var name: String { "TagMigration" }
		func prepare(on database: any Database) async throws {
			try await database.schema(Tag.schema)
				.id()
				.field(Tag.FieldKeys.name, .string, .required)
				.field(Tag.FieldKeys.createdAt, .datetime)
				.field(Tag.FieldKeys.updatedAt, .datetime)
				.field(Tag.FieldKeys.isDeleted, .bool, .custom("DEFAULT FALSE"))
				.create()
		}
		func revert(on database: any Database) async throws {
			try await database.schema(Tag.schema).delete()
		}
	}
}
